/*
 * CodeSaveCommand.java
 *
 * Created on 2006년 3월 29일 (수), 오후 4:11
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.joinhawaii.home;

import java.util.*;



import javax.servlet.*;
import javax.servlet.http.*;

import org.json.simple.JSONObject;

import com.zll.framework.model.HashBox;
import com.zll.framework.model.HashList;
import com.zll.framework.servlet.Command;
import com.joinhawaii.common.CommonDAO;
import com.joinhawaii.common.CommonUtil;





/**
 *
 * @author eastar
 */
public class LoginCommand implements Command
{

    public String execute(HttpServletRequest  request, HttpServletResponse response)
    throws Exception
    {
		JSONObject json = new JSONObject();


    	HashBox box = new HashBox(request);



		HomeDAO dao 		= new HomeDAO();

		HashList list = dao.selectReqCustomer(box.getParam());


		HashMap result		= new HashMap();

		if (list.size() > 0) {

			HttpSession session = request.getSession();
			session.setAttribute("session.email_addr", list.get("email_addr",0));
			session.setAttribute("session.password", list.get("password",0));

			result.put("result", 	"true");
			result.put("action",	"/home/confirmReq.jsp?pmenu_id="+box.get("pmenu_id")+"&menu_id="+box.get("menu_id"));

	    	request.setAttribute("result", result);

	    	return "/common/move_view.jsp";
	    } else {
	    	result.put("result", 	"false");
	    	result.put("message", 	"INVALID_LOGIN");
			result.put("action",	"/home/login.jsp?pmenu_id="+box.get("pmenu_id")+"&menu_id="+box.get("menu_id"));

	    	request.setAttribute("result", result);

	    	return "/common/move_view.jsp";
	    }

    }
}
